package com.tcwong.config;

import com.tcwong.mapper.UserMapper;
import com.tcwong.proxy.MapperProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.lang.reflect.Proxy;

/**
 * Description
 *
 * @author tcwong
 * @date 2022/1/15
 * Since 1.8
 */
@Configuration
public class MapperProxyConfig {


    @Bean
    public UserMapper userMapper(){
        MapperProxy mapperProxy = new MapperProxy();
        Object proxyInstance = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{UserMapper.class}, mapperProxy);
        return (UserMapper)proxyInstance;
    }
}
